﻿#include "plcconfig.h"
#include "ui_plcconfig.h"

#include"plcconfigadd.h"
PlcConfig::PlcConfig(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::PlcConfig)
{
    ui->setupUi(this);

    ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定");
    ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消");

    QFont font =  ui->tableWidget->horizontalHeader()->font();                                   //获取字体格式
    font.setBold(true);

    ui->tableWidget->verticalHeader()->setVisible(false);                                           //设置tableWidget左侧行标签隐藏
    ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);                            //设置tableWidget内容外部不可编辑
    ui->tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background:#404040;color:#ffffff}");//设置表头背景和字体颜色
    ui->tableWidget->horizontalHeader()->setFont(font);                                             //设置表头字体加粗
    ui->tableWidget->setFont(QFont("song", 12));                                                    //设置表头字体大小为12号


    ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);      //自适应列宽
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);    //自适应行宽
}

PlcConfig::~PlcConfig()
{
    delete ui;
}

void PlcConfig::on_actionAdd_triggered()
{
    PlcConfigAdd *a=new PlcConfigAdd;
    a->setWindowTitle("增加PLC信号");
    a->setFixedSize(500,400);
    a->show();
}

void PlcConfig::on_buttonBox_clicked(QAbstractButton *button)
{
    if(button == static_cast<QAbstractButton *>(ui->buttonBox->button(QDialogButtonBox::Ok)))
        {
            this->close();
        }
        else if(button == ui->buttonBox->button(QDialogButtonBox::Cancel))
        {
            this->close();
        }
}
